//
//  AddEventViewController.m
//  mosad_hw_fin
//
//  Created by student9 on 2020/12/24.
//  Copyright © 2020 student9. All rights reserved.
//

#import "AddEventViewController.h"

@interface AddEventViewController ()<LMJDropdownMenuDataSource,LMJDropdownMenuDelegate> {
    NSString *date_weekly_post;
    int hour_weekly_post;
    int minute_weekly_post;
    NSString *detail_weekly_post;
    
    int hour_daily_post;
    int minute_daily_post;
    NSString *detail_daily_post;
    
    int year_once_post;
    int month_once_post;
    int day_once_post;
    int hour_once_post;
    int minute_once_post;
    NSString *detail_once_post;
}
@property (nonatomic, strong) UIButton *weekly_btn;
@property (nonatomic, strong) UIButton *daily_btn;
@property (nonatomic, strong) UIButton *once_btn;
@property (nonatomic, strong) UILabel *date_label;

@property (nonatomic, strong) NSArray *menu2OptionTitles;
@property (nonatomic, strong) NSMutableArray *hourOptionTitles;
@property (nonatomic, strong) NSMutableArray *minuteOptionTitles;

@property (nonatomic, strong) UIView *notlogin_pic;
@property (nonatomic, strong) UILabel *notlogin_label;

// weekly
@property (nonatomic, strong) UILabel *weekly_date_label;
@property (nonatomic, strong) LMJDropdownMenu * menu2;
@property (nonatomic, strong) UILabel *start_time_label;
@property (nonatomic, strong) UITextField *start_time_weekly; // 以下三个一体
@property (nonatomic, strong) UIDatePicker * datepicker_text_weekly;
@property (nonatomic, strong) UIToolbar * toobarForDatepicker_weekly;
@property (nonatomic, strong) UILabel *detail_label;
@property (nonatomic, strong) UITextField *detail_input;

// daily
@property (nonatomic, strong) UILabel *start_time_label_daily;
@property (nonatomic, strong) UITextField *start_time_daily; // 以下三个一体
@property (nonatomic, strong) UIDatePicker * datepicker_text_daily;
@property (nonatomic, strong) UIToolbar * toobarForDatepicker_daily;
@property (nonatomic, strong) UILabel *detail_label_daily;
@property (nonatomic, strong) UITextField *detail_input_daily;

// once
@property (nonatomic, strong) UILabel *date_label_once;
@property (nonatomic, strong) UITextField *date_once; // 以下三个一体
@property(nonatomic , strong) UIDatePicker * datepicker_text;
@property(nonatomic , strong) UIToolbar * toobarForDatepicker;
@property (nonatomic, strong) UILabel *start_time_label_once;
@property (nonatomic, strong) UITextField *start_time_once; // 以下三个一体
@property(nonatomic , strong) UIDatePicker * datepicker_text_start_time;
@property(nonatomic , strong) UIToolbar * toobarForDatepicker_start_time;
@property (nonatomic, strong) UILabel *detail_label_once;
@property (nonatomic, strong) UITextField *detail_input_once;

@property (nonatomic, strong) UIButton *weekly_charify_btn;
@property (nonatomic, strong) UIButton *daily_charify_btn;
@property (nonatomic, strong) UIButton *once_charitfy_btn;
@end

@implementation AddEventViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _weekly_btn.backgroundColor = [UIColor clearColor];
    _daily_btn.backgroundColor = [UIColor clearColor];
    _once_btn.backgroundColor = [UIColor clearColor];
    _menu2OptionTitles = @[@"星期日",@"星期一",@"星期二",@"星期三",@"星期四",@"星期五",@"星期六"];
    _minuteOptionTitles = [[NSMutableArray alloc] init];
    _hourOptionTitles = [[NSMutableArray alloc] init];
    
    for (NSInteger i = 0; i < 60; i++) {
        NSString *obj = [NSString stringWithFormat:@"%ld分", i];
        [_minuteOptionTitles addObject:obj];
    }
    for (NSInteger i = 0; i < 24; i++) {
        NSString *obj = [NSString stringWithFormat:@"%ld时", i];
        [_hourOptionTitles addObject:obj];
    }
    
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"background_pic.png" ] ];
    self.navigationController.navigationBar.hidden = YES;
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    __weak typeof(self) weakSelf = self;
    
    UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 40)];
    textLabel.text = @"添加事件";
    textLabel.font = [UIFont fontWithName:@"FZZJ-TJHWBJW"  size:(30)];
    textLabel.textColor = [UIColor blackColor];
    [self.view addSubview:textLabel];
    [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.view).offset(weakSelf.view.frame.size.height / 10);
        make.size.mas_equalTo(CGSizeMake(150, 40));
        make.left.equalTo(weakSelf.view).offset(weakSelf.view.frame.size.width / 10);
    }];
    
    UILabel *sentLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 30)];
    sentLabel.text = @"纯粹是对生命最好的诠释。";
    sentLabel.textColor = [UIColor blackColor];
    [self.view addSubview:sentLabel];
    [sentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(textLabel.mas_bottom).offset(0);
        make.size.mas_equalTo(CGSizeMake(300, 30));
        make.left.equalTo(weakSelf.view).offset(weakSelf.view.frame.size.width / 10);
    }];
    
    _weekly_btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0,(weakSelf.view.frame.size.width - 60) / 3 , 60)];
    _weekly_btn.backgroundColor = [UIColor clearColor];
    [_weekly_btn setTitle:@"周常事件" forState:UIControlStateNormal];
    [_weekly_btn setTitleColor:[UIColor colorWithRed:123/255.0 green:104/255.0 blue:238/255.0 alpha:1] forState:UIControlStateNormal];
    [_weekly_btn.layer setMasksToBounds:YES];
    [_weekly_btn.layer setCornerRadius:10.0];
    [_weekly_btn addTarget:self
                   action:@selector(weekly_press:)
         forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_weekly_btn];
    [_weekly_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(sentLabel.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake((weakSelf.view.frame.size.width - 60) / 3 , 60));
        make.left.equalTo(weakSelf.view).offset(30);
    }];

    _daily_btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0,(weakSelf.view.frame.size.width - 60) / 3 , 60)];
    _daily_btn.backgroundColor = [UIColor clearColor];
    [_daily_btn setTitle:@"日常事件" forState:UIControlStateNormal];
    [_daily_btn setTitleColor:[UIColor colorWithRed:123/255.0 green:104/255.0 blue:238/255.0 alpha:1] forState:UIControlStateNormal];
    [_daily_btn.layer setMasksToBounds:YES];
    [_daily_btn.layer setCornerRadius:10.0];
    [_daily_btn addTarget:self
                      action:@selector(daily_press:)
            forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_daily_btn];
    [_daily_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(sentLabel.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake((weakSelf.view.frame.size.width - 60) / 3 , 60));
        make.left.equalTo(self->_weekly_btn.mas_right).offset(0);
    }];
    
    _once_btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0,(weakSelf.view.frame.size.width - 60) / 3 , 60)];
    _once_btn.backgroundColor = [UIColor clearColor];
    [_once_btn setTitle:@"单次事件" forState:UIControlStateNormal];
    [_once_btn setTitleColor:[UIColor colorWithRed:123/255.0 green:104/255.0 blue:238/255.0 alpha:1] forState:UIControlStateNormal];
    [_once_btn.layer setMasksToBounds:YES];
    [_once_btn.layer setCornerRadius:10.0];
    [_once_btn addTarget:self
                   action:@selector(once_press:)
         forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_once_btn];
    [_once_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(sentLabel.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake((weakSelf.view.frame.size.width - 60) / 3 , 60));
        make.left.equalTo(self->_daily_btn.mas_right).offset(0);
    }];
    
    UIView *borderMine = [[UIView alloc] initWithFrame: CGRectMake(0, 0, weakSelf.view.frame.size.width - 60, weakSelf.view.frame.size.height - 280)];
    borderMine.backgroundColor = [UIColor whiteColor];
    borderMine.layer.cornerRadius = 5;
    borderMine.layer.masksToBounds = YES;
    [self.view addSubview:borderMine];
    [borderMine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(weakSelf.view.frame.size.width - 60, weakSelf.view.frame.size.height - 280));
        make.centerX.equalTo(weakSelf.view.mas_centerX);
        make.top.mas_equalTo(self->_once_btn.mas_bottom).offset(-10);
    }];
    
    _weekly_date_label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    _weekly_date_label.text = @"日期";
    [self.view addSubview:_weekly_date_label];
    [_weekly_date_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 40));
        make.left.mas_equalTo(borderMine.mas_left).offset(45);
        make.top.mas_equalTo(borderMine.mas_top).offset(30);
    }];
    
    _menu2 = [[LMJDropdownMenu alloc] initWithFrame:CGRectMake(160, 235, 150, 25)];
    _menu2.dataSource = self;
    _menu2.delegate   = self;
    _menu2.layer.borderColor  = [UIColor blackColor].CGColor;
    _menu2.layer.borderWidth  = 1;
    _menu2.title           = @"请选择星期";
    _menu2.titleBgColor    = [UIColor whiteColor];
    _menu2.titleFont       = [UIFont boldSystemFontOfSize:15];
    _menu2.titleColor      = [UIColor colorWithRed:123/255.0 green:104/255.0 blue:238/255.0 alpha:1];
    _menu2.titleAlignment  = NSTextAlignmentCenter;
    _menu2.titleEdgeInsets = UIEdgeInsetsZero;
    _menu2.optionBgColor       = [UIColor whiteColor];
    _menu2.optionFont          = [UIFont systemFontOfSize:12];
    _menu2.optionTextColor     = [UIColor blackColor];
    _menu2.optionTextAlignment = NSTextAlignmentCenter;
    _menu2.optionNumberOfLines = 0;
    _menu2.optionLineColor     = [UIColor blackColor];
    _menu2.optionLineHeight    = 1;
    _menu2.showsVerticalScrollIndicatorOfOptionsList = NO;
    _menu2.layer.cornerRadius = 5;
    [self.view addSubview:_menu2];
    
    _start_time_label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    _start_time_label.text = @"时间";
    [self.view addSubview:_start_time_label];
    [_start_time_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 40));
        make.left.mas_equalTo(borderMine.mas_left).offset(45);
        make.top.mas_equalTo(self->_weekly_date_label.mas_bottom).offset(20);
    }];
    
    _start_time_weekly = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 25)];
    _start_time_weekly.placeholder = @"EE : mm";
    _start_time_weekly.layer.borderWidth= 1.0;
    _start_time_weekly.borderStyle = UITextBorderStyleNone;
    _start_time_weekly.layer.borderColor= [UIColor blackColor].CGColor;
    _start_time_weekly.layer.cornerRadius = 5;
    _start_time_weekly.clearButtonMode = UITextFieldViewModeWhileEditing;
    _start_time_weekly.inputView = self.datepicker_text_weekly;
    _start_time_weekly.inputAccessoryView = self.toobarForDatepicker_weekly;
    [_start_time_weekly setLeftView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 0)]];
    [_start_time_weekly setLeftViewMode:UITextFieldViewModeAlways];
    _start_time_weekly.layer.hidden = NO;
    [_start_time_weekly addTarget:self
                   action:@selector(input_start_time_weekly:)
         forControlEvents:UIControlEventEditingChanged];
    [self.view addSubview:_start_time_weekly];
    [_start_time_weekly mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 25));
        make.left.mas_equalTo(self->_menu2.mas_left).offset(0);
        make.top.mas_equalTo(self->_menu2.mas_bottom).offset(35);
    }];
    
    _detail_label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    _detail_label.text = @"简述";
    [self.view addSubview:_detail_label];
    [_detail_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 40));
        make.left.mas_equalTo(borderMine.mas_left).offset(45);
        make.top.mas_equalTo(self->_start_time_label.mas_bottom).offset(20);
    }];
    
    _detail_input = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 25)];
    _detail_input.layer.borderWidth= 1.0;
    _detail_input.borderStyle = UITextBorderStyleNone;
    _detail_input.layer.borderColor= [UIColor blackColor].CGColor;
    _detail_input.layer.cornerRadius = 5;
    _detail_input.clearButtonMode = UITextFieldViewModeWhileEditing;
    _detail_input.autocorrectionType = UITextAutocorrectionTypeNo;
    _detail_input.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [_detail_input setLeftView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 0)]];
    [_detail_input setLeftViewMode:UITextFieldViewModeAlways];
    [_detail_input addTarget:self
                           action:@selector(input_detail_weekly:)
                 forControlEvents:UIControlEventEditingChanged];
    [self.view addSubview:_detail_input];
    [_detail_input mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 25));
        make.left.mas_equalTo(self->_menu2.mas_left).offset(0);
        make.top.mas_equalTo(self->_detail_label.mas_top).offset(8);
    }];
    
    _weekly_charify_btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
    _weekly_charify_btn.backgroundColor = [UIColor colorWithRed:123/255.0 green:104/255.0 blue:238/255.0 alpha:0.7];
    [_weekly_charify_btn setTitle:@"确定" forState:UIControlStateNormal];
    [_weekly_charify_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _weekly_charify_btn.layer.cornerRadius = 10;
    _weekly_charify_btn.layer.hidden = NO;
    [_weekly_charify_btn addTarget:self
                  action:@selector(weekly_btn_press:)
        forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_weekly_charify_btn];
    [_weekly_charify_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(200, 50));
        make.bottom.mas_equalTo(borderMine.mas_bottom).offset(-30);
        make.centerX.mas_equalTo(borderMine.mas_centerX);
    }];
    
    _start_time_label_daily = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    _start_time_label_daily.text = @"时间";
    _start_time_label_daily.layer.hidden = YES;
    [self.view addSubview:_start_time_label_daily];
    [_start_time_label_daily mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 40));
        make.left.mas_equalTo(borderMine.mas_left).offset(45);
        make.top.mas_equalTo(borderMine.mas_top).offset(30);
    }];
    
    _start_time_daily = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 25)];
    _start_time_daily.placeholder = @"EE : mm";
    _start_time_daily.layer.borderWidth= 1.0;
    _start_time_daily.borderStyle = UITextBorderStyleNone;
    _start_time_daily.layer.borderColor= [UIColor blackColor].CGColor;
    _start_time_daily.layer.cornerRadius = 5;
    _start_time_daily.clearButtonMode = UITextFieldViewModeWhileEditing;
    _start_time_daily.inputView = self.datepicker_text_daily;
    _start_time_daily.inputAccessoryView = self.toobarForDatepicker_daily;
    [_start_time_daily setLeftView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 0)]];
    [_start_time_daily setLeftViewMode:UITextFieldViewModeAlways];
    _start_time_daily.layer.hidden = YES;
    [self.view addSubview:_start_time_daily];
    [_start_time_daily mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 25));
        make.left.mas_equalTo(self->_start_time_label_daily.mas_right).offset(0);
        make.top.mas_equalTo(borderMine.mas_top).offset(38);
    }];
    
    _detail_label_daily = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    _detail_label_daily.text = @"时间";
    _detail_label_daily.layer.hidden = YES;
    [self.view addSubview:_detail_label_daily];
    [_detail_label_daily mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 40));
        make.left.mas_equalTo(borderMine.mas_left).offset(45);
        make.top.mas_equalTo(borderMine.mas_top).offset(30);
    }];
    
    _detail_label_daily = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    _detail_label_daily.text = @"简述";
    _detail_label_daily.layer.hidden = YES;
    [self.view addSubview:_detail_label_daily];
    [_detail_label_daily mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 40));
        make.left.mas_equalTo(borderMine.mas_left).offset(45);
        make.top.mas_equalTo(self->_start_time_daily.mas_bottom).offset(20);
    }];
    
    _detail_input_daily = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 25)];
    _detail_input_daily.layer.borderWidth= 1.0;
    _detail_input_daily.borderStyle = UITextBorderStyleNone;
    _detail_input_daily.layer.borderColor= [UIColor blackColor].CGColor;
    _detail_input_daily.layer.cornerRadius = 5;
    _detail_input_daily.clearButtonMode = UITextFieldViewModeWhileEditing;
    _detail_input_daily.autocorrectionType = UITextAutocorrectionTypeNo;
    _detail_input_daily.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [_detail_input_daily setLeftView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 0)]];
    [_detail_input_daily setLeftViewMode:UITextFieldViewModeAlways];
    _detail_input_daily.layer.hidden = YES;
    [_detail_input_daily addTarget:self
                      action:@selector(input_detail_daily:)
            forControlEvents:UIControlEventEditingChanged];
    [self.view addSubview:_detail_input_daily];
    [_detail_input_daily mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 25));
        make.left.mas_equalTo(self->_detail_label_daily.mas_right).offset(0);
        make.top.mas_equalTo(self->_start_time_daily.mas_bottom).offset(28);
    }];
    
    _daily_charify_btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
    _daily_charify_btn.backgroundColor = [UIColor colorWithRed:123/255.0 green:104/255.0 blue:238/255.0 alpha:0.7];
    [_daily_charify_btn setTitle:@"确定" forState:UIControlStateNormal];
    [_daily_charify_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _daily_charify_btn.layer.cornerRadius = 10;
    _daily_charify_btn.layer.hidden = YES;
    [_daily_charify_btn addTarget:self
                            action:@selector(daily_btn_press:)
                  forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_daily_charify_btn];
    [_daily_charify_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(200, 50));
        make.bottom.mas_equalTo(borderMine.mas_bottom).offset(-30);
        make.centerX.mas_equalTo(borderMine.mas_centerX);
    }];
    
    _date_label_once = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    _date_label_once.text = @"日期";
    _date_label_once.layer.hidden = YES;
    [self.view addSubview:_date_label_once];
    [_date_label_once mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 40));
        make.left.mas_equalTo(borderMine.mas_left).offset(45);
        make.top.mas_equalTo(borderMine.mas_top).offset(30);
    }];
    
    _date_once = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 25)];
    _date_once.placeholder = @"YYYY / MM / dd";
    _date_once.layer.borderWidth= 1.0;
    _date_once.borderStyle = UITextBorderStyleNone;
    _date_once.layer.borderColor= [UIColor blackColor].CGColor;
    _date_once.layer.cornerRadius = 5;
    _date_once.clearButtonMode = UITextFieldViewModeWhileEditing;
    _date_once.inputView = self.datepicker_text;
    _date_once.inputAccessoryView = self.toobarForDatepicker;
    [_date_once setLeftView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 0)]];
    [_date_once setLeftViewMode:UITextFieldViewModeAlways];
    _date_once.layer.hidden = YES;
    [self.view addSubview:_date_once];
    [_date_once mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 25));
        make.left.mas_equalTo(self->_date_label_once.mas_right).offset(0);
        make.top.mas_equalTo(borderMine.mas_top).offset(38);
    }];
    
    _start_time_label_once = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    _start_time_label_once.text = @"时间";
    _start_time_label_once.layer.hidden = YES;
    [self.view addSubview:_start_time_label_once];
    [_start_time_label_once mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 40));
        make.left.mas_equalTo(borderMine.mas_left).offset(45);
        make.top.mas_equalTo(self->_date_label_once.mas_bottom).offset(20);
    }];
    
    _start_time_once = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 25)];
    _start_time_once.placeholder = @"EE : mm";
    _start_time_once.layer.borderWidth= 1.0;
    _start_time_once.borderStyle = UITextBorderStyleNone;
    _start_time_once.layer.borderColor= [UIColor blackColor].CGColor;
    _start_time_once.layer.cornerRadius = 5;
    _start_time_once.clearButtonMode = UITextFieldViewModeWhileEditing;
    _start_time_once.inputView = self.datepicker_text_start_time;
    _start_time_once.inputAccessoryView = self.toobarForDatepicker_start_time;
    [_start_time_once setLeftView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 0)]];
    [_start_time_once setLeftViewMode:UITextFieldViewModeAlways];
    _start_time_once.layer.hidden = YES;
    [self.view addSubview:_start_time_once];
    [_start_time_once mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 25));
        make.left.mas_equalTo(self->_start_time_label_once.mas_right).offset(0);
        make.top.mas_equalTo(self->_date_once.mas_bottom).offset(35);
    }];
    
    _detail_label_once = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    _detail_label_once.text = @"简述";
    _detail_label_once.layer.hidden = YES;
    [self.view addSubview:_detail_label_once];
    [_detail_label_once mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 40));
        make.left.mas_equalTo(borderMine.mas_left).offset(45);
        make.top.mas_equalTo(self->_start_time_label_once.mas_bottom).offset(20);
    }];
    
    _detail_input_once = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 25)];
    _detail_input_once.layer.borderWidth= 1.0;
    _detail_input_once.borderStyle = UITextBorderStyleNone;
    _detail_input_once.layer.borderColor= [UIColor blackColor].CGColor;
    _detail_input_once.layer.cornerRadius = 5;
    _detail_input_once.clearButtonMode = UITextFieldViewModeWhileEditing;
    _detail_input_once.autocorrectionType = UITextAutocorrectionTypeNo;
    _detail_input_once.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [_detail_input_once setLeftView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 0)]];
    [_detail_input_once setLeftViewMode:UITextFieldViewModeAlways];
    _detail_input_once.layer.hidden = YES;
    [_detail_input_once addTarget:self
                            action:@selector(input_detail_once:)
                  forControlEvents:UIControlEventEditingChanged];
    [self.view addSubview:_detail_input_once];
    [_detail_input_once mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 25));
        make.left.mas_equalTo(self->_detail_label_once.mas_right).offset(0);
        make.top.mas_equalTo(self->_start_time_once.mas_bottom).offset(35);
    }];

    _once_charitfy_btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
    _once_charitfy_btn.backgroundColor = [UIColor colorWithRed:123/255.0 green:104/255.0 blue:238/255.0 alpha:0.7];
    [_once_charitfy_btn setTitle:@"确定" forState:UIControlStateNormal];
    [_once_charitfy_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _once_charitfy_btn.layer.cornerRadius = 10;
    _once_charitfy_btn.layer.hidden = YES;
    [_once_charitfy_btn addTarget:self
                           action:@selector(once_btn_press:)
                 forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_once_charitfy_btn];
    [_once_charitfy_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(200, 50));
        make.bottom.mas_equalTo(borderMine.mas_bottom).offset(-30);
        make.centerX.mas_equalTo(borderMine.mas_centerX);
    }];
    
    _notlogin_pic = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
    _notlogin_pic.backgroundColor = [UIColor colorWithPatternImage:[[UIImage imageNamed:@"warning.png"] TransformtoSize:CGSizeMake(200, 200)]];
    [self.view addSubview:_notlogin_pic];
    [_notlogin_pic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(200, 200));
        make.centerX.mas_equalTo(borderMine.mas_centerX);
        make.centerY.mas_equalTo(borderMine.mas_centerY);
    }];
    
    _notlogin_label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 40)];
    _notlogin_label.text = @"请先登录！";
    _notlogin_label.layer.hidden = YES;
    _notlogin_label.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:_notlogin_label];
    [_notlogin_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(200, 40));
        make.centerX.mas_equalTo(borderMine.mas_centerX);
        make.top.mas_equalTo(self->_notlogin_pic.mas_bottom).offset(20);
    }];
    
    [self judge_not_login];
}

- (void) judge_not_login {
    headimageModel *current_head_image = [headimageModel shareInstance];
    if ([current_head_image.ID isEqualToString:@"notlogin"] == YES) {
        _weekly_charify_btn.layer.hidden = YES;
        _daily_charify_btn.layer.hidden = YES;
        _once_charitfy_btn.layer.hidden = YES;
        
        _weekly_date_label.layer.hidden = YES;
        _menu2.layer.hidden = YES;
        _start_time_label.layer.hidden = YES;
        _start_time_weekly.layer.hidden = YES;
        _detail_label.layer.hidden = YES;
        _detail_input.layer.hidden = YES;
        
        _start_time_label_daily.layer.hidden = YES;
        _start_time_daily.layer.hidden = YES;
        _detail_label_daily.layer.hidden = YES;
        _detail_input_daily.layer.hidden = YES;
        
        _date_label_once.layer.hidden = YES;
        _date_once.layer.hidden = YES;
        _start_time_label_once.layer.hidden = YES;
        _start_time_once.layer.hidden = YES;
        _detail_label_once.layer.hidden = YES;
        _detail_input_once.layer.hidden = YES;
        
        _notlogin_pic.layer.hidden = NO;
        _notlogin_label.layer.hidden = NO;
        
        _weekly_btn.userInteractionEnabled = NO;
        _daily_btn.userInteractionEnabled = NO;
        _once_btn.userInteractionEnabled = NO;
    } else {
        _notlogin_pic.layer.hidden = YES;
        _notlogin_label.layer.hidden = YES;
    }
}

-(UIDatePicker *)datepicker_text {
    if (!_datepicker_text) {
        _datepicker_text = [[UIDatePicker alloc] init];
        _datepicker_text.datePickerMode = UIDatePickerModeDate;
        _datepicker_text.locale = [NSLocale localeWithLocaleIdentifier:@"zh-Hans"];
    }
    return _datepicker_text;
}

-(UIToolbar *)toobarForDatepicker {
    if (!_toobarForDatepicker) {
        _toobarForDatepicker = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 0, 50)];
        UIBarButtonItem * cancelItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancelClick)];
        UIBarButtonItem * springItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        UIBarButtonItem * confirmItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(confirmClick)];
        _toobarForDatepicker.items = @[cancelItem,springItem,confirmItem];
    }
    return _toobarForDatepicker;
}

-(void)cancelClick {
    //收回键盘
    [self.view endEditing:YES];
}

-(void)confirmClick {
    NSDate * currentDate = self.datepicker_text.date;
    NSDateFormatter * dateformatter = [[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"YYYY / MM / dd"];
    NSString * currentDate_string = [dateformatter stringFromDate:currentDate];
    self->_date_once.text = currentDate_string;
    NSArray *array = [self->_date_once.text componentsSeparatedByString:@" / "];
    self->year_once_post =  [[array objectAtIndex:0] intValue];
    self->month_once_post =  [[array objectAtIndex:1] intValue];
    self->day_once_post =  [[array objectAtIndex:2] intValue];
    [self.view endEditing:YES];
}

-(UIDatePicker *)datepicker_text_start_time {
    if (!_datepicker_text_start_time) {
        _datepicker_text_start_time = [[UIDatePicker alloc] init];
        _datepicker_text_start_time.datePickerMode = UIDatePickerModeTime;
        _datepicker_text_start_time.locale = [NSLocale localeWithLocaleIdentifier:@"zh-Hans"];
    }
    return _datepicker_text_start_time;
}

-(UIToolbar *)toobarForDatepicker_start_time {
    if (!_toobarForDatepicker_start_time) {
        _toobarForDatepicker_start_time = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 0, 50)];
        UIBarButtonItem * cancelItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancelClick_start_time)];
        UIBarButtonItem * springItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        UIBarButtonItem * confirmItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(confirmClick_start_time)];
        _toobarForDatepicker_start_time.items = @[cancelItem,springItem,confirmItem];
    }
    return _toobarForDatepicker_start_time;
}

-(void)cancelClick_start_time {
    //收回键盘
    [self.view endEditing:YES];
}

-(void)confirmClick_start_time {
    NSDate * currentDate = self.datepicker_text_start_time.date;
    NSDateFormatter * dateformatter = [[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"HH : mm"];
    NSString * currentDate_string = [dateformatter stringFromDate:currentDate];
    self->_start_time_once.text = currentDate_string;
    NSArray *array = [self->_start_time_once.text componentsSeparatedByString:@" : "];
    self->hour_once_post = [[array firstObject] intValue];
    self->minute_once_post = [[array lastObject] intValue];
    [self.view endEditing:YES];
}

-(UIDatePicker *)datepicker_text_weekly {
    if (!_datepicker_text_weekly) {
        _datepicker_text_weekly = [[UIDatePicker alloc] init];
        _datepicker_text_weekly.datePickerMode = UIDatePickerModeTime;
        _datepicker_text_weekly.locale = [NSLocale localeWithLocaleIdentifier:@"zh-Hans"];
    }
    return _datepicker_text_weekly;
}

-(UIToolbar *)toobarForDatepicker_weekly {
    if (!_toobarForDatepicker_weekly) {
        _toobarForDatepicker_weekly = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 0, 50)];
        UIBarButtonItem * cancelItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancelClick_weekly)];
        UIBarButtonItem * springItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        UIBarButtonItem * confirmItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(confirmClick_weekly)];
        _toobarForDatepicker_weekly.items = @[cancelItem,springItem,confirmItem];
    }
    return _toobarForDatepicker_weekly;
}

-(void)cancelClick_weekly {
    //收回键盘
    [self.view endEditing:YES];
}

-(void)confirmClick_weekly {
    NSDate * currentDate = self.datepicker_text_weekly.date;
    NSDateFormatter * dateformatter = [[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"HH : mm"];
    NSString * currentDate_string = [dateformatter stringFromDate:currentDate];
    self->_start_time_weekly.text = currentDate_string;
    NSArray *array = [self->_start_time_weekly.text componentsSeparatedByString:@" : "];
    self->hour_weekly_post = [[array firstObject] intValue];
    self->minute_weekly_post = [[array lastObject] intValue];
    [self.view endEditing:YES];
}

-(UIDatePicker *)datepicker_text_daily {
    if (!_datepicker_text_daily) {
        _datepicker_text_daily = [[UIDatePicker alloc] init];
        _datepicker_text_daily.datePickerMode = UIDatePickerModeTime;
        _datepicker_text_daily.locale = [NSLocale localeWithLocaleIdentifier:@"zh-Hans"];
    }
    return _datepicker_text_daily;
}

-(UIToolbar *)toobarForDatepicker_daily {
    if (!_toobarForDatepicker_daily) {
        _toobarForDatepicker_daily = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 0, 50)];
        UIBarButtonItem * cancelItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancelClick_daily)];
        UIBarButtonItem * springItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        UIBarButtonItem * confirmItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(confirmClick_daily)];
        _toobarForDatepicker_daily.items = @[cancelItem,springItem,confirmItem];
    }
    return _toobarForDatepicker_daily;
}

-(void)cancelClick_daily {
    //收回键盘
    [self.view endEditing:YES];
}

-(void)confirmClick_daily {
    NSDate * currentDate = self.datepicker_text_daily.date;
    NSDateFormatter * dateformatter = [[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"HH : mm"];
    NSString * currentDate_string = [dateformatter stringFromDate:currentDate];
    self->_start_time_daily.text = currentDate_string;
    NSArray *array = [self->_start_time_daily.text componentsSeparatedByString:@" : "];
    self->hour_daily_post = [[array firstObject] intValue];
    self->minute_daily_post = [[array lastObject] intValue];
    [self.view endEditing:YES];
}

- (void)weekly_press:(UIButton *)buttonView {
    _weekly_btn.backgroundColor = [UIColor whiteColor];
    _daily_btn.backgroundColor = [UIColor clearColor];
    _once_btn.backgroundColor = [UIColor clearColor];
    _weekly_date_label.text = @"日期";
    
    _weekly_charify_btn.layer.hidden = NO;
    _daily_charify_btn.layer.hidden = YES;
    _once_charitfy_btn.layer.hidden = YES;
    
    _weekly_date_label.layer.hidden = NO;
    _menu2.layer.hidden = NO;
    _start_time_label.layer.hidden = NO;
    _start_time_weekly.layer.hidden = NO;
    _detail_label.layer.hidden = NO;
    _detail_input.layer.hidden = NO;
    
    _start_time_label_daily.layer.hidden = YES;
    _start_time_daily.layer.hidden = YES;
    _detail_label_daily.layer.hidden = YES;
    _detail_input_daily.layer.hidden = YES;
    
    _date_label_once.layer.hidden = YES;
    _date_once.layer.hidden = YES;
    _start_time_label_once.layer.hidden = YES;
    _start_time_once.layer.hidden = YES;
    _detail_label_once.layer.hidden = YES;
    _detail_input_once.layer.hidden = YES;
}

- (void)daily_press:(UIButton *)buttonView {
    _weekly_btn.backgroundColor = [UIColor clearColor];
    _daily_btn.backgroundColor = [UIColor whiteColor];
    _once_btn.backgroundColor = [UIColor clearColor];
    
    _weekly_charify_btn.layer.hidden = YES;
    _daily_charify_btn.layer.hidden = NO;
    _once_charitfy_btn.layer.hidden = YES;
    
    _weekly_date_label.layer.hidden = YES;
    _menu2.layer.hidden = YES;
    _start_time_label.layer.hidden = YES;
    _start_time_weekly.layer.hidden = YES;
    _detail_label.layer.hidden = YES;
    _detail_input.layer.hidden = YES;
    
    _start_time_label_daily.layer.hidden = NO;
    _start_time_daily.layer.hidden = NO;
    _detail_label_daily.layer.hidden = NO;
    _detail_input_daily.layer.hidden = NO;
    
    _date_label_once.layer.hidden = YES;
    _date_once.layer.hidden = YES;
    _start_time_label_once.layer.hidden = YES;
    _start_time_once.layer.hidden = YES;
    _detail_label_once.layer.hidden = YES;
    _detail_input_once.layer.hidden = YES;
}

- (void)once_press:(UIButton *)buttonView {
    _weekly_btn.backgroundColor = [UIColor clearColor];
    _daily_btn.backgroundColor = [UIColor clearColor];
    _once_btn.backgroundColor = [UIColor whiteColor];
    
    _weekly_charify_btn.layer.hidden = YES;
    _daily_charify_btn.layer.hidden = YES;
    _once_charitfy_btn.layer.hidden = NO;
    
    _weekly_date_label.layer.hidden = YES;
    _menu2.layer.hidden = YES;
    _start_time_label.layer.hidden = YES;
    _start_time_weekly.layer.hidden = YES;
    _detail_label.layer.hidden = YES;
    _detail_input.layer.hidden = YES;
    
    _start_time_label_daily.layer.hidden = YES;
    _start_time_daily.layer.hidden = YES;
    _detail_label_daily.layer.hidden = YES;
    _detail_input_daily.layer.hidden = YES;
    
    _date_label_once.layer.hidden = NO;
    _date_once.layer.hidden = NO;
    _start_time_label_once.layer.hidden = NO;
    _start_time_once.layer.hidden = NO;
    _detail_label_once.layer.hidden = NO;
    _detail_input_once.layer.hidden = NO;
}

#pragma mark - LMJDropdownMenu DataSource
- (NSUInteger)numberOfOptionsInDropdownMenu:(LMJDropdownMenu *)menu{
    if (menu == self->_menu2) {
        return self->_menu2OptionTitles.count;
    }
    return 0;
}

- (CGFloat)dropdownMenu:(LMJDropdownMenu *)menu heightForOptionAtIndex:(NSUInteger)index{
    return 25;
}

- (NSString *)dropdownMenu:(LMJDropdownMenu *)menu titleForOptionAtIndex:(NSUInteger)index{
    if (menu == self->_menu2) {
        return self->_menu2OptionTitles[index];
    }
    return @"";
}

- (UIImage *)dropdownMenu:(LMJDropdownMenu *)menu iconForOptionAtIndex:(NSUInteger)index{
    return nil;
}

#pragma mark - LMJDropdownMenu Delegate
- (void)dropdownMenu:(LMJDropdownMenu *)menu didSelectOptionAtIndex:(NSUInteger)index optionTitle:(NSString *)title{
    NSLog(@"你选择了(you selected)：menu2，index: %ld - title: %@", index, title);
    self->date_weekly_post = title;
}

- (void)dropdownMenuWillShow:(LMJDropdownMenu *)menu{
}

- (void)dropdownMenuDidShow:(LMJDropdownMenu *)menu{
}

- (void)dropdownMenuWillHidden:(LMJDropdownMenu *)menu{
}

- (void)dropdownMenuDidHidden:(LMJDropdownMenu *)menu{
}

- (void) input_start_time_weekly:(UITextField*) sender {

}

- (void) input_detail_weekly:(UITextField*) sender {
    self->detail_weekly_post = sender.text;
}

- (void)weekly_btn_press:(UIButton *)buttonView {
    headimageModel *current_head_image = [headimageModel shareInstance];
    NSLog(@"%@, %d, %d, %@", self->date_weekly_post, self->hour_weekly_post, self->minute_weekly_post, self->detail_weekly_post);
    NSNumber *date_post_f;
    if ([self->date_weekly_post isEqualToString:@"星期一"]) {
        date_post_f = [NSNumber numberWithInt:1];
    } else if ([self->date_weekly_post isEqualToString:@"星期二"]) {
        date_post_f = [NSNumber numberWithInt:2];
    } else if ([self->date_weekly_post isEqualToString:@"星期三"]) {
        date_post_f = [NSNumber numberWithInt:3];
    } else if ([self->date_weekly_post isEqualToString:@"星期四"]) {
        date_post_f = [NSNumber numberWithInt:4];
    } else if ([self->date_weekly_post isEqualToString:@"星期五"]) {
        date_post_f = [NSNumber numberWithInt:5];
    } else if ([self->date_weekly_post isEqualToString:@"星期六"]) {
        date_post_f = [NSNumber numberWithInt:6];
    } else if ([self->date_weekly_post isEqualToString:@"星期日"]) {
        date_post_f = [NSNumber numberWithInt:7];
    }
    NSNumber *hour_post_f = [NSNumber numberWithInt:self->hour_weekly_post];
    NSNumber *minute_post_f = [NSNumber numberWithInt:self->minute_weekly_post];
    NSString *owner_post_f = [[NSString alloc] initWithFormat:@"%@", current_head_image.ID];
    NSString *detail_post_f = [[NSString alloc] initWithFormat:@"%@", self->detail_weekly_post];
    [self doPostRequestWithOwnid:owner_post_f
                        WithWeek: date_post_f
                        WithHour:hour_post_f
                      WithMinute:minute_post_f
                     WithContent:detail_post_f];
}

- (void) doPostRequestWithOwnid: (NSString *) ownid
                       WithWeek: (NSNumber *) week
                       WithHour: (NSNumber *)  hour
                     WithMinute: (NSNumber *) minute
                    WithContent: (NSString *) content {
    AFHTTPSessionManager *manager =[AFHTTPSessionManager manager];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    NSDictionary *dict = @{
                           @"OwnID": ownid,
                           @"Week": week,
                           @"Hour": hour,
                           @"Min": minute,
                           @"Content": content
                           };
    NSLog(@"dict: %@", dict);
    headimageModel *current_head_image = [headimageModel shareInstance];
    NSString *current_url = [current_head_image.host_str stringByAppendingString:@"Weekly/add"];
    [manager POST:current_url
       parameters:dict
          headers:nil
         progress:^(NSProgress * _Nonnull downloadProgress) {
             //进度
         } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
             // 请求成功
             if ([responseObject[@"state"] boolValue]) {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     NSLog(@"%@", responseObject[@"response"]);
                     self->_detail_input.text = @"";
                     self->_start_time_weekly.text = @"";
                     self->_menu2.title = @"请选择星期";
                     [self showAlertMsgWithStr: @"添加事件成功"];
                 });
             } else {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     NSLog(@"%@", responseObject[@"response"]);
                     [self showAlertMsgWithStr: @"添加事件失败"];
                 });
             }
         } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
             // 请求失败
         }];
}

- (void) input_detail_daily:(UITextField*) sender {
    self->detail_daily_post = sender.text;
}

- (void)daily_btn_press:(UIButton *)buttonView {
    headimageModel *current_head_image = [headimageModel shareInstance];
    NSLog(@"%@, %d, %d, %@", current_head_image.ID, self->hour_daily_post, self->minute_daily_post, self->detail_daily_post);
    NSNumber *hour_post_f = [NSNumber numberWithInt:self->hour_daily_post];
    NSNumber *minute_post_f = [NSNumber numberWithInt:self->minute_daily_post];
    NSString *owner_post_f = [[NSString alloc] initWithFormat:@"%@", current_head_image.ID];
    NSString *detail_post_f = [[NSString alloc] initWithFormat:@"%@", self->detail_daily_post];
    [self doPostRequestWithOwnid:owner_post_f
                        WithHour:hour_post_f
                      WithMinute:minute_post_f
                     WithContent:detail_post_f];
}

- (void) doPostRequestWithOwnid: (NSString *) ownid
                       WithHour: (NSNumber *)  hour
                     WithMinute: (NSNumber *) minute
                    WithContent: (NSString *) content {
    AFHTTPSessionManager *manager =[AFHTTPSessionManager manager];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    NSDictionary *dict = @{
                           @"OwnID": ownid,
                           @"Hour": hour,
                           @"Min": minute,
                           @"Content": content
                           };
    NSLog(@"dict: %@", dict);
    headimageModel *current_head_image = [headimageModel shareInstance];
    NSString *current_url = [current_head_image.host_str stringByAppendingString:@"Daily/add"];
    [manager POST:current_url
       parameters:dict
          headers:nil
         progress:^(NSProgress * _Nonnull downloadProgress) {
             //进度
         } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
             // 请求成功
             if ([responseObject[@"state"] boolValue]) {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     NSLog(@"%@", responseObject[@"response"]);
                     self->_detail_input_daily.text = @"";
                     self->_start_time_daily.text = @"";
                     [self showAlertMsgWithStr: @"添加事件成功"];
                 });
             } else {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     NSLog(@"%@", responseObject[@"response"]);
                     [self showAlertMsgWithStr: @"添加事件失败"];
                 });
             }
         } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
             // 请求失败
         }];
}

- (void) input_detail_once:(UITextField*) sender {
    self->detail_once_post = sender.text;
}

- (void)once_btn_press:(UIButton *)buttonView {
    headimageModel *current_head_image = [headimageModel shareInstance];
    NSLog(@"%@, %d, %d, %d, %d, %d, %@", current_head_image.ID, self->year_once_post, self->month_once_post, self->day_once_post, self->hour_once_post, self->minute_once_post, self->detail_once_post);
    NSNumber *year_post_f = [NSNumber numberWithInt:self->year_once_post];
    NSNumber *month_post_f = [NSNumber numberWithInt:self->month_once_post];
    NSNumber *day_post_f = [NSNumber numberWithInt:self->day_once_post];
    NSNumber *hour_post_f = [NSNumber numberWithInt:self->hour_once_post];
    NSNumber *minute_post_f = [NSNumber numberWithInt:self->minute_once_post];
    NSString *owner_post_f = [[NSString alloc] initWithFormat:@"%@", current_head_image.ID];
    NSString *detail_post_f = [[NSString alloc] initWithFormat:@"%@", self->detail_once_post];
    [self doPostRequestWithOwnid:owner_post_f
                        WithYear:year_post_f
                      WithMinute:month_post_f
                         WithDay:day_post_f
                        WithHour:hour_post_f
                      WithMinute:minute_post_f
                     WithContent:detail_post_f];
}

- (void) doPostRequestWithOwnid: (NSString *) ownid
                       WithYear: (NSNumber *)  year
                     WithMinute: (NSNumber *)  month
                        WithDay: (NSNumber *)  day
                       WithHour: (NSNumber *)  hour
                     WithMinute: (NSNumber *) minute
                    WithContent: (NSString *) content {
    AFHTTPSessionManager *manager =[AFHTTPSessionManager manager];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    NSDictionary *dict = @{
                           @"OwnID": ownid,
                           @"Year": year,
                           @"Month": month,
                           @"Day": day,
                           @"Hour": hour,
                           @"Min": minute,
                           @"Content": content
                           };
    NSLog(@"dict: %@", dict);
    headimageModel *current_head_image = [headimageModel shareInstance];
    NSString *current_url = [current_head_image.host_str stringByAppendingString:@"Onetime/add"];
    [manager POST:current_url
       parameters:dict
          headers:nil
         progress:^(NSProgress * _Nonnull downloadProgress) {
             //进度
         } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
             // 请求成功
             if ([responseObject[@"state"] boolValue]) {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     NSLog(@"%@", responseObject[@"response"]);
                     self->_detail_input_once.text = @"";
                     self->_start_time_once.text = @"";
                     self->_date_once.text = @"";
                     [self showAlertMsgWithStr: @"添加事件成功"];
                 });
             } else {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     NSLog(@"%@", responseObject[@"response"]);
                     [self showAlertMsgWithStr: @"添加事件失败"];
                 });
             }
         } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
             // 请求失败
         }];
}

-(void)showAlertMsgWithStr: (NSString *)str {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIView *showview =  [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width - 200, 60)];
        showview.backgroundColor = [UIColor blackColor];
        showview.alpha = 1.0f;
        showview.layer.cornerRadius = 5.0f;
        showview.layer.masksToBounds = YES;
        [self.view addSubview:showview];
        
        UILabel *str_label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width - 200, 60)];
        str_label.textColor = [UIColor whiteColor];
        str_label.textAlignment = NSTextAlignmentCenter;
        str_label.text = str;
        [showview addSubview:str_label];
        [str_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width - 200, 60));
            make.centerY.mas_equalTo(showview.mas_centerY);
            make.centerX.mas_equalTo(showview.mas_centerX);
        }];
        
        [showview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width - 200, 60));
            make.centerX.mas_equalTo(self.view.mas_centerX);
            make.centerY.mas_equalTo(self.view.mas_centerY);
        }];
        [UIView animateWithDuration:1 animations:^{
            showview.alpha = 0;
        } completion:^(BOOL finished) {
            [showview removeFromSuperview];
        }];
    });
}

- (void) viewDidAppear:(BOOL)animated {
    [self viewDidLoad];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
